package com.gz.EuchreU.Sprite;

import org.anddev.andengine.entity.modifier.MoveModifier;
import org.anddev.andengine.entity.sprite.Sprite;

import com.badlogic.gdx.math.Vector2;
import com.gz.EuchreU.Contants.UI;
import com.gz.EuchreU.Helpers.HelperMethods;

public class ButtonSprite extends Sprite{

	private boolean mEnabled = true;
	
	public ButtonSprite(float pX, float pY, float pWidth,int pTextureID) {
		super(pX, pY, pWidth, 
			UI.getTextures().getHeightFromWidth(pTextureID, pWidth),
			UI.getTextures().getTexture(pTextureID));
	}
	
	public boolean Enabled(){
		return mEnabled;
	}
	
	@Override
	protected void onManagedUpdate(final float pSecondsElapsed) {
		super.onManagedUpdate(pSecondsElapsed);
	}
	
	public void SetEnabled(boolean pEnabled){
		mEnabled = pEnabled;
		
		if(mEnabled){
			setColor(1f, 1f, 1f);
			setAlpha(1f);
		}
		else {
			setColor(.0f, .0f, .0f);
			setAlpha(.0f);
		}
		setRotation(0);
	}
	
	public void MoveTo(Vector2 pMoveToLocation){
		double distance = HelperMethods.getDistanceFromPointToPoint(pMoveToLocation, new Vector2(getX(),getY()));
		if(distance < 5 && distance > -5){
			return;
		}
		
		
		float duration = 2;
		
		
//		
//		ParallelShapeModifier mod = new ParallelShapeModifier(
//			new MoveModifier(duration, getX(), pMoveToLocation.x, getY(), pMoveToLocation.y, EaseStrongOut.getInstance())
//		);
		
		MoveModifier mod = new MoveModifier(duration, getX(), pMoveToLocation.x, getY(), pMoveToLocation.y);
		
		this.clearEntityModifiers();
		this.registerEntityModifier(mod);
		//clearShapeModifiers();
		//addShapeModifier(mod);
	}
	
//	private void log(String msg){
//		if(mTextureID == TextureRegions.TEXTURE_DEALER){
//			Log.d("DealerButton",msg);
//		}
//	}
}
